//
//  HalfImageAndWordsCollectionCell.m
//  ArtDog
//
//  Created by dllo on 16/9/1.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HalfImageAndWordsCollectionCell.h"
#import "UIImageView+WebCache.h"
#import "HomeExhibitList.h"
#import "HomeTopicList.h"
#import "ReadMainModel.h"

@interface HalfImageAndWordsCollectionCell ()

@property (weak, nonatomic) IBOutlet UIImageView *picImageView;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UIView *lineView;

@property (weak, nonatomic) IBOutlet UIView *lineViewVert;
@property (weak, nonatomic) IBOutlet UILabel *viewerLabel;
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;

@property (weak, nonatomic) IBOutlet UILabel *galleryLabel;

@property (weak, nonatomic) IBOutlet UILabel *dateLabel;

@property (weak, nonatomic) IBOutlet UILabel *cityLabel;

@end

@implementation HalfImageAndWordsCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)prepareForReuse
{
    _dateLabel.text = nil;
    _cityLabel.text = nil;
    _galleryLabel.text = nil;
}

- (void)setTopicModel:(HomeTopicList *)topicModel
{
    _topicModel = topicModel;
    _lineView.hidden = YES;
    _lineViewVert.hidden = YES;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:topicModel.topicPic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    [style setLineSpacing:3.0f];
    _nameLabel.attributedText = [[NSAttributedString alloc]initWithString:topicModel.topicName attributes:@{NSParagraphStyleAttributeName: style}];
    _viewerLabel.text = [NSString stringWithFormat:@"%@", topicModel.viewerNum];
    _commentLabel.text = [NSString stringWithFormat:@"%@", topicModel.joinNum];
}

- (void)setReadModel:(ReadMainModel *)readModel
{
    _readModel = readModel;
    _lineView.hidden = YES;
    _lineViewVert.hidden = YES;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:readModel.topicPic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    [style setLineSpacing:3.0f];
    _nameLabel.attributedText = [[NSAttributedString alloc]initWithString:readModel.topicName == nil ? @"": readModel.topicName attributes:@{NSParagraphStyleAttributeName: style}];
    _viewerLabel.text = [NSString stringWithFormat:@"%@", readModel.viewerNum];
    _commentLabel.text = [NSString stringWithFormat:@"%@", readModel.joinNum];
}

- (void)setExhibitModel:(HomeExhibitList *)exhibitModel
{
    _exhibitModel = exhibitModel;
    _lineView.hidden = NO;
    _lineViewVert.hidden = NO;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:exhibitModel.exhibitPic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
    [style setLineSpacing:3.0f];
    _nameLabel.attributedText = [[NSAttributedString alloc]initWithString:exhibitModel.name attributes:@{NSParagraphStyleAttributeName: style}];
    _viewerLabel.text = [NSString stringWithFormat:@"%@", exhibitModel.viewerNum];
    _commentLabel.text = [NSString stringWithFormat:@"%@", exhibitModel.commentNum];
    _galleryLabel.text = exhibitModel.galleryName;
    _cityLabel.text = exhibitModel.exhibitCity;
    _dateLabel.text = [[[exhibitModel.exhibitStartDate componentsSeparatedByString:@" "][0] stringByAppendingString:@"-"]stringByAppendingString:[[exhibitModel.exhibitEndDate componentsSeparatedByString:@" "][0] substringFromIndex:5]];
}

@end
